package com.pai4j.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 群成员状态枚举
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum GroupMemberStatusEnum {

    NORMAL(1, "正常"),
    MUTED(2, "被禁言"),
    KICKED(3, "被踢出"),
    LEFT(4, "主动退群");

    private Integer status;
    private String statusName;

    /**
     * 判断是否为正常状态
     */
    public static boolean isNormal(Integer status) {
        return NORMAL.getStatus().equals(status);
    }

    /**
     * 判断是否被禁言
     */
    public static boolean isMuted(Integer status) {
        return MUTED.getStatus().equals(status);
    }

    /**
     * 判断是否被踢出
     */
    public static boolean isKicked(Integer status) {
        return KICKED.getStatus().equals(status);
    }

    /**
     * 判断是否主动退群
     */
    public static boolean isLeft(Integer status) {
        return LEFT.getStatus().equals(status);
    }

    /**
     * 判断是否还在群内（正常或禁言状态）
     */
    public static boolean isInGroup(Integer status) {
        return isNormal(status) || isMuted(status);
    }

    /**
     * 根据状态值获取枚举
     */
    public static GroupMemberStatusEnum getByStatus(Integer status) {
        for (GroupMemberStatusEnum statusEnum : values()) {
            if (statusEnum.getStatus().equals(status)) {
                return statusEnum;
            }
        }
        return null;
    }
}
